using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Silky.Core.Modularity;

namespace Microsoft.Extensions.Hosting
{
    public class DefaultWebHostModule : WebHostModule
    {
        public override void ConfigureServices(IServiceCollection services, IConfiguration configuration)
        {
            //if (!services.IsAdded(typeof(IServerRegister)))
            //{
            //    var registerType = configuration.GetValue<string>("registrycenter:type");
            //    if (registerType.IsNullOrEmpty())
            //    {
            //        throw new SilkyException("You did not specify the service registry type");
            //    }

            //    services.AddDefaultRegistryCenter(registerType);
            //}
        }

        public override async Task Shutdown(ApplicationContext applicationContext)
        {
            await Task.CompletedTask;
            //var serverRegister =
            //    applicationContext.ServiceProvider.GetRequiredService<IServerRegister>();
            //await serverRegister.RemoveSelf();
        }
    }
}